package com.bw.zg3.Cate.New

import androidx.paging.PagingData
import androidx.paging.PagingSource
import androidx.paging.PagingState
import com.bw.base.entity.NewEntityResultItem
import com.bw.base.net.ApiServer

@Suppress("UNUSED_EXPRESSION")
class NewSurce(val apiServer: ApiServer):PagingSource<Int,NewEntityResultItem>() {
    override fun getRefreshKey(state: PagingState<Int, NewEntityResultItem>): Int? {
       return null
    }

    override suspend fun load(params: LoadParams<Int>): LoadResult<Int, NewEntityResultItem> {
       try {
           val i = params.key ?: 0
           val net = apiServer.getNET()
           val i1 = if (net.data.size == 10) i + 1 else null
         return  LoadResult.Page(net.data,null,i1)

       }catch (e:Exception){
          return LoadResult.Error(e)
       }

    }
}